﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GC_VKMD.MusicDownloaderClient.Helpers.Presentation
{
	public class BoolToVisibilityConverter : IValueConverter
	{
		#region Properties

		public bool Collapse { get; set; }

		public bool Reverse { get; set; }

		#endregion

		#region IValueConverter Members

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var boolValue = (bool)value;

			return boolValue != Reverse
				? Visibility.Visible
				: (Collapse ? Visibility.Collapsed : Visibility.Hidden);
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var visibility = (Visibility)value;
			return visibility == Visibility.Visible ? !Reverse : Reverse;
		}

		#endregion
	}
}
